﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditZinas.aspx.cs" Inherits="EditZinas" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 512px;
        }
        .style3
        {
            width: 136px;
        }
        .style4
        {
            color: #FF0000;
        }
        .style5
        {
            color: #33CC33;
        }
    </style>
</head>
<body>
    <form id="formFileUpload" method="post"  enctype="Multipart/Form-Data" runat="Server">
    <div>
    
        <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" 
            LogoutPageUrl="~/Default.aspx" />
        <asp:LoginName ID="LoginName1" runat="server" />
    
        <asp:LinkButton ID="LinkButton1" runat="server" 
            PostBackUrl="~/edit_nedbilde.aspx">Edit Nedeļas Bilde</asp:LinkButton>
&nbsp;&nbsp;&nbsp;
        <asp:LinkButton ID="LinkButton2" runat="server" 
            PostBackUrl="~/login_izvele.aspx">Login Izvēlne</asp:LinkButton>
    
    </div>
    <table class="style1">
            <tr>
            <td class="style2">
                <asp:Button ID="Button_addIMG" runat="server" onclick="Button_addIMG_Click" 
                    Text="Add img to list" />
                <asp:Repeater ID="Repeater1" runat="server" 
                    onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound">
                <ItemTemplate> 
                    <asp:Button ID="Button1" runat="server" Text="Button" /> 
                    </ItemTemplate>
                </asp:Repeater>
                </td>
        </tr>
        <tr>
            <td class="style2">
                Titul bildes izmērs&nbsp; <span class="style5">W 600 x H 335</span><br />
                <asp:FileUpload ID="FileField" runat="server" size="50" 
                    ondatabinding="ButtonSaveNewRaksts_Click" Width="406px" />
                  
                &nbsp;<br />
                
                <asp:TextBox ID="TextBox1_imgURL" runat="server" Height="23px" Width="334px"></asp:TextBox>
                Mazās bildes hiperLinks, šī bilde rādīsies tikai Default lapā.<br />
                <br />
                Folder path:
                <asp:DropDownList ID="DDLFolders" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="DDLFolders_SelectedIndexChanged" >
                </asp:DropDownList>
                <br />
                <br />
                bilžu mapes                 
                <asp:DropDownList ID="DropDownListBildesMape" runat="server" >
                </asp:DropDownList>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:TextBox ID="TextBoxJaunaMape" runat="server"></asp:TextBox>
                &nbsp;
                <asp:Button ID="ButtonJaunaMape" runat="server" onclick="ButtonJaunaMape_Click" 
                    onload="Page_Load" PostBackUrl="~/EditZinas.aspx" Text="Jauna Mape" />
            </td>
            <td class="style3" rowspan="6" style="vertical-align: top">
                <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
                </asp:CheckBoxList>
            </td>
            <td>
                <asp:Button ID="Button2koment" runat="server" onclick="Button2koment_Click" 
                    Text="KomentCount" Width="100px" />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style2">
                Virsraksts
                <span class="style5">pareizi (text-text)</span> <span class="style4">nepareizi( 
                text - test )</span>&nbsp;<br />
                <asp:TextBox ID="TextBoxVirsraksts" runat="server" Width="321px" 
                    TextMode="MultiLine"></asp:TextBox>
            </td>
            <td rowspan="5">
                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
                    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="DisplayID" 
                    DataSourceID="SqlDataSource2" 
                    EmptyDataText="There are no data records to display." CellPadding="4" 
                    ForeColor="#333333" GridLines="None">
                    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:BoundField DataField="DisplayID" HeaderText="DisplayID" ReadOnly="True" 
                            SortExpression="DisplayID" />
                        <asp:BoundField DataField="RakstaID" HeaderText="RakstaID" 
                            SortExpression="RakstaID" />
                        <asp:BoundField DataField="SadalasID" HeaderText="SadalasID" 
                            SortExpression="SadalasID" />
                    </Columns>
                    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Raksts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style5">&nbsp;&lt;br/&gt; 
                liekas automātiski</span>
                <asp:TextBox ID="TextBoxNewRaksts" runat="server" Height="500px" 
                    TextMode="MultiLine" Width="494px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Autors:&nbsp;
                <asp:TextBox ID="TextBoxAutors" runat="server" Width="179px"></asp:TextBox>
                &nbsp;

            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Button ID="ButtonSaveNewRaksts" runat="server" 
                    onclick="ButtonSaveNewRaksts_Click" Text="Save" Width="90px" />  
                <asp:Label ID="Label_ERROR" runat="server" Text="" ForeColor="#FF0066" 
                    Font-Size="X-Large"></asp:Label>
            </td>
        </tr>

    </table>
    <br />
    <asp:GridView ID="GridView5" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID_name" 
        DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="ID_name" HeaderText="ID_name" ReadOnly="True" 
                SortExpression="ID_name" />
            <asp:BoundField DataField="datums" HeaderText="datums" 
                SortExpression="datums" />
            <asp:BoundField DataField="Virsraksts" HeaderText="Virsraksts" 
                SortExpression="Virsraksts" />
            <asp:BoundField DataField="bildeTumb" HeaderText="bildeTumb" 
                SortExpression="bildeTumb" />
            <asp:BoundField DataField="bilde" HeaderText="bilde" SortExpression="bilde" />
            <asp:BoundField DataField="MazaisRaksts" HeaderText="MazaisRaksts" 
                SortExpression="MazaisRaksts" />
            <asp:BoundField DataField="raksts" HeaderText="raksts" 
                SortExpression="raksts" />
            <asp:BoundField DataField="autors" HeaderText="autors" 
                SortExpression="autors" />
            <asp:BoundField DataField="SadaluLists" HeaderText="SadaluLists" 
                SortExpression="SadaluLists" />
            <asp:BoundField DataField="komentSkaits" HeaderText="komentSkaits" 
                SortExpression="komentSkaits" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyDB %>" 
        DeleteCommand="DELETE FROM [Raksti] WHERE [ID_name] = @ID_name" 
        InsertCommand="INSERT INTO [Raksti] ([datums], [Virsraksts], [bildeTumb], [bilde], [MazaisRaksts], [raksts], [autors], [SadaluLists], [komentSkaits]) VALUES (@datums, @Virsraksts, @bildeTumb, @bilde, @MazaisRaksts, @raksts, @autors, @SadaluLists, @komentSkaits)" 
        ProviderName="<%$ ConnectionStrings:MyDB.ProviderName %>" 
        SelectCommand="SELECT [ID_name], [datums], [Virsraksts], [bildeTumb], [bilde], [MazaisRaksts], [raksts], [autors], [SadaluLists], [komentSkaits] FROM [Raksti]" 
        UpdateCommand="UPDATE [Raksti] SET [datums] = @datums, [Virsraksts] = @Virsraksts, [bildeTumb] = @bildeTumb, [bilde] = @bilde, [MazaisRaksts] = @MazaisRaksts, [raksts] = @raksts, [autors] = @autors, [SadaluLists] = @SadaluLists, [komentSkaits] = @komentSkaits WHERE [ID_name] = @ID_name">
        <DeleteParameters>
            <asp:Parameter Name="ID_name" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="datums" Type="DateTime" />
            <asp:Parameter Name="Virsraksts" Type="String" />
            <asp:Parameter Name="bildeTumb" Type="String" />
            <asp:Parameter Name="bilde" Type="String" />
            <asp:Parameter Name="MazaisRaksts" Type="String" />
            <asp:Parameter Name="raksts" Type="String" />
            <asp:Parameter Name="autors" Type="String" />
            <asp:Parameter Name="SadaluLists" Type="String" />
            <asp:Parameter Name="komentSkaits" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="datums" Type="DateTime" />
            <asp:Parameter Name="Virsraksts" Type="String" />
            <asp:Parameter Name="bildeTumb" Type="String" />
            <asp:Parameter Name="bilde" Type="String" />
            <asp:Parameter Name="MazaisRaksts" Type="String" />
            <asp:Parameter Name="raksts" Type="String" />
            <asp:Parameter Name="autors" Type="String" />
            <asp:Parameter Name="SadaluLists" Type="String" />
            <asp:Parameter Name="komentSkaits" Type="Int32" />
            <asp:Parameter Name="ID_name" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyDB %>" 
        DeleteCommand="DELETE FROM [Display] WHERE [DisplayID] = @DisplayID" 
        InsertCommand="INSERT INTO [Display] ([RakstaID], [SadalasID]) VALUES (@RakstaID, @SadalasID)" 
        ProviderName="<%$ ConnectionStrings:MyDB.ProviderName %>" 
        SelectCommand="SELECT [DisplayID], [RakstaID], [SadalasID] FROM [Display]" 
        UpdateCommand="UPDATE [Display] SET [RakstaID] = @RakstaID, [SadalasID] = @SadalasID WHERE [DisplayID] = @DisplayID">
        <DeleteParameters>
            <asp:Parameter Name="DisplayID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="RakstaID" Type="Int32" />
            <asp:Parameter Name="SadalasID" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="RakstaID" Type="Int32" />
            <asp:Parameter Name="SadalasID" Type="Int32" />
            <asp:Parameter Name="DisplayID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <br />
    <asp:GridView ID="GridView4" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Sadalas_nameID" 
        DataSourceID="SqlDataSource4" 
        EmptyDataText="There are no data records to display." AutoGenerateEditButton="False" AutoGenerateDeleteButton="False">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowSelectButton="True" />
            <asp:TemplateField HeaderText="New">
                <ItemTemplate>
                    <asp:LinkButton ID="lblNew" runat="server" CausesValidation="false" CommandName="Insert"
                        Text="New" Style="vertical-align: middle; text-align: center" Font-Bold="False"
                        ForeColor="Black" Height="3px" Width="49px" OnClick="GridViewInsert">
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Sadalas_nameID" HeaderText="Sadalas_nameID" 
                InsertVisible="False" ReadOnly="True" SortExpression="Sadalas_nameID" />
            <asp:BoundField DataField="cat_name" HeaderText="cat_name" 
                SortExpression="cat_name" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyDB %>" 
        DeleteCommand="DELETE FROM [Sadala] WHERE [Sadalas_nameID] = @Sadalas_nameID" 
        InsertCommand="INSERT INTO [Sadala] ([cat_name]) VALUES (@cat_name)" 
        ProviderName="<%$ ConnectionStrings:MyDB.ProviderName %>" 
        SelectCommand="SELECT [Sadalas_nameID], [cat_name] FROM [Sadala]" 
        
        UpdateCommand="UPDATE [Sadala] SET [cat_name] = @cat_name WHERE [Sadalas_nameID] = @Sadalas_nameID" 
        oninserting="SqlDataSource4_Inserting">
        <DeleteParameters>
            <asp:Parameter Name="Sadalas_nameID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
        <asp:ControlParameter ControlID="GridView4"  DefaultValue="1" Name="cat_name" PropertyName="SelectedValue" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="cat_name" Type="String" />
            <asp:Parameter Name="Sadalas_nameID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <p>
        Fast way to Delet compleatley one News article form all database tables:</p>
    <p>
        <asp:TextBox ID="TextBox1DeletID" runat="server"></asp:TextBox>
&nbsp;Delet Article ID</p>
    <p>
        <asp:Button ID="Button2_DeletArticle" runat="server" 
            onclick="Button2_DeletArticle_Click" Text="Delet article" />
    &nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button2KomentSkaits" runat="server" 
            onclick="Button2KomentSkaits_Click" Text="Fill Koment_skaits" />
    </p>
    </form>
</body>
</html>
